// 样式
import './scss/index.scss'

// 插件
import element from './libs/element' // 饿了么
import nprogress from './libs/nprogress' // 路由切换进度条

// 组件
// import Form from './components/Form.vue'
import FormItem from './components/FormItem.vue'
import FormGroup from './components/FormGroup.vue'
import Input from './components/Input.vue'
import DialogEdit from './components/DialogEdit.vue'

const components = [
  { name: 'Input', component: Input },
  // { name: 'Form', component: Form },
  { name: 'FormItem', component: FormItem },
  { name: 'FormGroup', component: FormGroup },
  { name: 'Upload', component: defineAsyncComponent(() => import('./components/Upload.vue')) },
  { name: 'InputFile', component: defineAsyncComponent(() => import('./components/input-file/InputFile.vue')) },
  { name: 'Info', component: defineAsyncComponent(() => import('./components/Info.vue')) },
  { name: 'Desc', component: defineAsyncComponent(() => import('./components/Desc.vue')) },
  { name: 'DescItem', component: defineAsyncComponent(() => import('./components/DescItem.vue')) },
  { name: 'DialogEdit', component: DialogEdit },
  { name: 'DateRangePicker', component: defineAsyncComponent(() => import('./components/DateRangePicker.vue')) },
  { name: 'Image', component: defineAsyncComponent(() => import('./components/Image.vue')) },
]

export default {
  install(app, context) {
    // 注册组件
    components.forEach((item) => {
      const { name, component } = item
      const componentName = 'Jax' + name
      app.component(componentName, component)
    })

    // 引入饿了么
    app.use(element)

    // 路由切换进度条
    app.use(nprogress, context)
  },
}
